<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <title>优惠券管理</title>
    <meta name="decorator" content="default"/>
    <script type="text/javascript">
        $(document).ready(function () {

        });

        function page(n, s) {
            $("#pageNo").val(n);
            $("#pageSize").val(s);
            $("#searchForm").submit();
            return false;
        }
        function getIds() {
            var ids = [];
            $("input[name='ids']:checked").each(function () {
                ids.push({id:$(this).val(),name:$(this).attr("label")});
            });
            return ids;
        }
    </script>
</head>
<body>
<ul class="nav nav-tabs">
    <li class="active"><a href="${ctx}/shop/shop/hkShopCoupon/">优惠券列表</a></li>
    <%--<shiro:hasPermission name="shop:shop:hkShopCoupon:edit">
        <li><a href="${ctx}/shop/shop/hkShopCoupon/form">优惠券添加</a></li>
    </shiro:hasPermission>--%>
</ul>
<form:form id="searchForm" modelAttribute="hkShopCoupon" action="${ctx}/shop/shop/hkShopCoupon" method="post"
           class="breadcrumb form-search">
    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
    <input id="checked" name="checked" type="hidden" value="${hkShopCoupon.checked}"/>
    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
    <ul class="ul-form">
        <li><label>标题：</label>
            <form:input path="title" htmlEscape="false" maxlength="100" class="input-medium"/>
        </li>
        <li><label>状态：</label>
            <form:select path="state" class="input-medium">
                <form:option value="" label=""/>
                <form:options items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value"
                              htmlEscape="false"/>
            </form:select>
        </li>
        <li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
        <li class="clearfix"></li>
    </ul>
</form:form>
<sys:message content="${message}"/>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
    <thead>
    <tr>
        <c:if test="${not empty hkShopCoupon.checked}">
            <th>选择</th>
        </c:if>
        <th>标题</th>
        <th>开始时间</th>
        <th>库存</th>
        <th>结束时间</th>
        <th>状态</th>
        <th>商品id</th>
        <th>折扣</th>
        <th>更新时间</th>
        <th>备注</th>
        <shiro:hasPermission name="shop:shop:hkShopCoupon:edit">
            <c:if test="${ empty hkShopCoupon.checked}">
                <th>操作</th>
            </c:if>
        </shiro:hasPermission>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${page.list}" var="hkShopCoupon2">
        <tr>
            <c:if test="${not empty hkShopCoupon.checked}">
                <td>
                    <input type="checkbox" name="ids" value="${hkShopCoupon2.id}" label="${hkShopCoupon2.title}">
                </td>
            </c:if>
            <td>
                <c:if test="${not empty hkShopCoupon.checked}">
                    ${hkShopCoupon2.title}
                </c:if>
                <c:if test="${ empty hkShopCoupon.checked}">
                    <a href="${ctx}/shop/shop/hkShopCoupon/form?id=${hkShopCoupon2.id}">
                            ${hkShopCoupon2.title}
                    </a>
                </c:if>
            </td>
            <td>
                <fmt:formatDate value="${hkShopCoupon2.beginTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
            </td>
            <td>
                    ${hkShopCoupon2.stocks}
            </td>
            <td>
                <fmt:formatDate value="${hkShopCoupon2.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
            </td>
            <td>
                    ${fns:getDictLabel(hkShopCoupon2.state, 'yes_no', '')}
            </td>
            <td>
                    ${hkShopCoupon2.product.id}
            </td>
            <td>
                    ${hkShopCoupon2.discount}
            </td>
            <td>
                <fmt:formatDate value="${hkShopCoupon2.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
            </td>
            <td>
                    ${hkShopCoupon2.remarks}
            </td>
            <c:if test="${ empty hkShopCoupon.checked}">
                <shiro:hasPermission name="shop:shop:hkShopCoupon:edit">
                    <td>
                        <a href="${ctx}/shop/shop/hkShopCoupon/form?id=${hkShopCoupon2.id}">修改</a>
                        <a href="${ctx}/shop/shop/hkShopCoupon/delete?id=${hkShopCoupon2.id}"
                           onclick="return confirmx('确认要删除该优惠券吗？', this.href)">删除</a>
                    </td>
                </shiro:hasPermission>
            </c:if>
        </tr>
    </c:forEach>
    </tbody>
</table>
<div class="pagination">${page}</div>
</body>
</html>